import axios from 'axios'
import conf from '@/utils/conf'

axios.defaults.timeout = 50000;
axios.defaults.baseURL = conf.api;
// axios.defaults.baseURL = 'http://localhost';

axios.defaults.adapter = function (config) {
    let {url, data, method} = config;
    return new Promise((resolve, reject) => {
        wx.request({
            url,
            data,
            header:{
                code : wx.getStorageSync('token')
            },
            method,
            success: res => {
                resolve(res);
            },
            fail: err => {
                reject(err);
            },
            complete: res => {
                // cb && cb(res)
            }
        });
    })
}

export default axios;